<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="css/jquery-ui-1.8.22.custom.css"
	type="text/css">
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.22.custom.min.js" type="text/javascript"></script>
<script>
	$(function() {
		$("#datepicker").datepicker();
	});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Offer Management</title>
</head>
<body>
	Add an offer
	<div>
	<form action="/offerAdmin/add">
		Issuing Bank: <select name="offeringCompanyId">
			<c:forEach items="${ allOfferingCompanies}" var="eachCompany">
				<option value="${eachCompany.id }">${eachCompany.companyName }</option>
			</c:forEach>
		</select> Card Type: <select name = "cardTypeId">
			<c:forEach items="${ allCardTypes}" var="cardType">
				<option value="${cardType.id }">${cardType.cardType}</option>
			</c:forEach>
		</select> Shopping category: <select name = "shoppingCategoryId">
			<c:forEach items="${ allCategories}" var="eachCategory">
				<option value="${eachCategory.id }">${eachCategory.shoppingCategory }</option>
			</c:forEach>
		</select> Merchant: <select name="merchantNameId">
			<c:forEach items="${ allMerchants}" var="eachMerchant">
				<option value="${eachMerchant.id }">${eachMerchant.merchantName }</option>
			</c:forEach>
		</select> Offer Text: <input type="text" name ="offerText"/> Terms and Conditions URL <input
			type="text" name="tAndCURL"/>
		<div class="demo">
			Valid Upto: <input id="datepicker" type="text" name="validUpto">
		</div>
		<input type="submit" value="Submit">
	</form>	
	</div>
	<c:if test="${not empty allOffers }">
		<table>
			<thead>
				<tr>
					<th>Issuing Bank</th>
					<th>Card Type</th>
					<th>Shopping category</th>
					<th>Merchant</th>
					<th>Offer Text</th>
					<th>Terms and Conditions URL</th>
					<th>Valid Upto</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${allOffers}" var="eachOffer">
					<tr>
						<td>${eachOffer.creditCardCompany.companyName }</td>
						<td>${eachOffer.creditCardType.cardType }</td>	
						<td>${eachOffer.shoppingCategory.shoppingCategory }</td>
						<td>${eachOffer.merchant.merchantName }</td>
						<td>${eachOffer.offerText }</td>
						<td>${eachOffer.termsAndConditionsURL }</td>
						<td><fmt:formatDate value="${eachOffer.validUpto.time }" type="date" dateStyle="short"/></td>
						<td><a href="/offerAdmin/delete?offerId=${eachOffer.id }">Delete</a></td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</c:if>
</body>
</html>